package cn.xd.itstack.springframework.context.support;

import cn.xd.itstack.springframework.beans.factory.ConfigurableListableBeanFactory;
import cn.xd.itstack.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * @Classname AbstractRefreshableApplicationContext
 * @Description TODO
 * @Date 2022/5/18 上午10:24
 * @Created by lvxiaodong
 */
public abstract class AbstractRefreshableApplicationContext extends AbstractApplicationContext {

    private DefaultListableBeanFactory defaultListableBeanFactory;


    @Override
    public void refreshBeanFactory(){
        DefaultListableBeanFactory beanFactory = createBeanFactory();
        loadBeanDefinitions(beanFactory);
        this.defaultListableBeanFactory = beanFactory;
    }


    public ConfigurableListableBeanFactory getBeanFactory(){
        return defaultListableBeanFactory;
    }

    protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);

    /**
     * 创建DefaultListableBeanFactory
     * @return
     */
    private DefaultListableBeanFactory createBeanFactory(){
        return new DefaultListableBeanFactory();
    }






}
